! function (e, t, i) {
    var a = e.Model.ModelBase,
        n = "WE.Shop.Model";
    e.namespace(n, a.extend({
        name: n,
        defaults: function () {
            return {
                type: "",
                point: "",
                rangeway: "rangeAll",
                price: 2,
                pageIndex: 0,
                pageSize: 10,
                pageCount: 0,
                data: []
            }
        },
        initialize: function () { },
        initEvents: function () { },
        parse: function (e) {
            var t = [];
            return _.each(e, function (e) {
                t.push({
                    id: e.id,
                    title: e.name,
                    image: e.pic_url,
                    state: parseInt(e.type),
                    price: e.price
                })
            }), t
        },
        getDateDiff: function (e, t) {
            var i = t.getTime() - e.getTime();
            return Math.floor(i / 864e5)
        }
    }))
}(WE, jQuery, Backbone),
function (e, t, i) {
    var a = e.View.ViewBase,
        n = "WE.Shop.View";
    e.namespace(n, a.extend({
        name: n,
        template: "",
        ELEMENT: {
            WIDTH: 270,
            HEIGHT: 515
        },
        initialize: function (e) {
            this.model = e.model, this.initEvents(), this.render(), this.initPageEvents()
        },
        initEvents: function () {
            var e = this;
            this.model.on("change:pageIndex", function () {
                e.loadData()
            }), this.model.on("change:data", function () {
                e.append()
            })
        },
        initPageEvents: function () {
            var e = this;
            $(".rangeList li").click(function () {
                $(this).addClass("focus").siblings().removeClass("focus");
                var t = $(this).attr("id");
                e.model.set({
                    rangeway: t,
                    pageIndex: 1
                }, {
                    silent: !0
                }), e.model.trigger("change:pageIndex")
            }), $(".menuList1 li").click(function () {
                var t = $(this).find("a").text();
                $(this).parent().parent().parent().find("dd").find("a").text(t);
                var i = $(this).attr("query");
                switch ($(this).parent().attr("tempFilter", $(this).attr("query")), i) {
                    case "all":
                        i = 0;
                        break;
                    case "english":
                        i = 1;
                        break;
                    case "chinese":
                        i = 2;
                        break;
                    case "little":
                        i = 3;
                        break;
                    case "pack":
                        i = 4;
                        break;
                    case "production":
                        i = 5;
                        break;
                    case "creative":
                        i = 6;
                        break;
                    case "letter":
                        i = 7
                }
                e.model.set({
                    type: i,
                    pageIndex: 1
                }, {
                    silent: !0
                }), e.model.trigger("change:pageIndex")
            }), $(".menuList2 li").click(function () {
                var t = $(this).find("a").text();
                $(this).parent().parent().parent().find("dd").find("a").text(t);
                var i = $(this).attr("query");
                switch ($(this).parent().attr("tempFilter", $(this).attr("query")), i) {
                    case "all":
                        i = 0;
                        break;
                    case "work":
                        i = 1;
                        break;
                    case "edu":
                        i = 2;
                        break;
                    case "school":
                        i = 3;
                        break;
                    case "skill":
                        i = 4;
                        break;
                    case "prize":
                        i = 5;
                        break;
                    case "conb":
                        i = 6;
                        break;
                    case "conl":
                        i = 7
                }
                e.model.set({
                    point: i,
                    pageIndex: 1
                }, {
                    silent: !0
                }), e.model.trigger("change:pageIndex")
            }), $(".selectItem li.getItem").hover(function () {
                $(this).find(".modelMenu").delay(150).slideDown(250).end().find(".rightArrow").css({
                    "-webkit-transform": "rotate(180deg)",
                    "-ms-transform": "rotate(180deg)",
                    transform: "rotate(180deg)"
                })
            }, function () {
                $(this).find(".modelMenu").delay(150).slideUp(250).end().find(".rightArrow").css({
                    "-webkit-transform": "rotate(0deg)",
                    "-ms-transform": "rotate(0deg)",
                    transform: "rotate(0deg)"
                })
            }), e.getCart(), this.ui.cart.click(function () {
                return window.$App.User.isLogin() ? (window.location.href = "pay_step_one.html", void (window.location.target =
                    "_blank")) : void window.$App.Login.showLogin()
            }), this.ui.document.scroll(function () {
                e.scroll()
            })
        },
        render: function () {
            this.ui = {}, this.ui.body = $("body"), this.ui.main = $(".filterGroup"), this.ui.document = $(document),
                this.ui.wrap = $(".filterResultWrap"), this.ui.empty = $("#empty"), this.ui.tips = $(".tips"), this.ui.guideBox =
                $(".guideBox"), this.ui.selection = $(".selection"), this.ui.cart = $("#cart"), this.model.set({
                    pageIndex: 1
                })
        },
        getCart: function () {
            if (null != $.cookie(e.Constant.COOKIE_TOKEN)) {
                var t = {};
                t.data = {}, t.success = function (e) {
                    $("#cart span").text(e.data.length)
                }, t.error = function (e) { }, e.Api.getShoppingCart(t, this)
            }
        },
        append: function () {
            var t = this.model.get("data"),
                i = this.model.get("pageIndex");
            1 == i && this.ui.wrap.empty();
            for (var a = 0; a < t.length; a++) {
                var n = new e.Template.WordMain(t[a]);
                this.ui.wrap.append(n.getElement())
            }
            this.isLoading = !1, setTimeout(function () { }, 1e3)
        },
        scroll: function () {
            var e = this.ui.wrap.find("li").eq(-1),
                t = this.model.get("pageIndex"),
                i = this.model.get("pageCount");
            if (!this.isLoading && e) {
                var a = this.ui.document.scrollTop() + $(window).height(),
                    n = Math.floor(e.height() / 2);
                n += e.offset() ? e.offset().top : 0, a > n && i >= t + 1 && (this.isLoading = !0, this.model.set({
                    pageIndex: t + 1
                }))
            }
        },
        loadData: function () {
            var t = ($(".switchEn").attr("language"), {});
            t.data = {
                type: this.model.get("type"),
                point: this.model.get("point"),
                rangeway: this.model.get("rangeway"),
                pageIndex: this.model.get("pageIndex"),
                pageSize: this.model.get("pageSize")
            }, t.success = function (e) {
                var t = e.data.list;
                this.model.set({
                    pageCount: e.data.pageCount || 1,
                    data: this.model.parse(t)
                }, {
                    silent: !0
                }), this.model.trigger("change:data")
            }, t.error = function (e) {
                this.model.trigger("change:pageIndex")
            }, e.Api.getWordList(t, this)
        }
    })); {
        var s = new e.Shop.Model;
        new e.Shop.View({
            model: s
        })
    }
}(WE, jQuery, Backbone);